﻿<UserControl x:Class="CYPlayer.ProjectViews.PlayerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:vm="clr-namespace:CYPlayer.ViewModel"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:custom="clr-namespace:CustomSliderLib;assembly=CustomSliderLib"
             xmlns:converter="clr-namespace:CYPlayer.Converter"
             xmlns:projectViews="clr-namespace:CYPlayer.ProjectViews"
             mc:Ignorable="d" Height="370" Width="426" >
    <UserControl.Resources>
        <converter:DoubleToTimeSpanConverter x:Key="DoubleConverter"></converter:DoubleToTimeSpanConverter>
        <converter:TimeSpanToDoubleConverter x:Key="TimeSpanConverter"></converter:TimeSpanToDoubleConverter>
    </UserControl.Resources>
    <UserControl.DataContext>
        <vm:PlayerWindowVM/>
    </UserControl.DataContext>
    <Grid Height="370">
        <DockPanel LastChildFill="True">
            <Border Background="GhostWhite" DockPanel.Dock="Top" Height="30">
                <TextBlock FontFamily="Segoe UI" FontSize="16" Foreground="Black" HorizontalAlignment="Center">
                    <Run Text="Just Player" /></TextBlock>
            </Border>
            <Border Background="{DynamicResource MyBackTitleBrush}" DockPanel.Dock="Top" Height="25">
                <TextBlock FontSize="16" Foreground="White" Name="sngName_tb" Text="{Binding SelectedSong.Title}" 
                           TextAlignment="Center" TextWrapping="Wrap" />
            </Border>
            <Border Background="WhiteSmoke" CornerRadius="3" DockPanel.Dock="Bottom" Height="90" Padding="1">
                <Grid Background="PowderBlue" >
                    
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="61*" />
                        <ColumnDefinition Width="206*" />
                        <ColumnDefinition Width="94*" />
                        <ColumnDefinition Width="63*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="3*" />
                    </Grid.RowDefinitions>

                    <custom:CustomSlider Grid.Column="1" Grid.ColumnSpan="2" x:Name="Slider"
                                         Minimum="{Binding MinimumValue, Converter={StaticResource DoubleConverter}}"
                                         Maximum="{Binding ElementName=FileLengthText, Mode=OneWay, Path=Text, Converter={StaticResource TimeSpanConverter}, ConverterParameter=string}"
                                         
                                         Value="{Binding CurrentPosition, Converter={StaticResource TimeSpanConverter}}">
                    </custom:CustomSlider>
                    

                    <StackPanel Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Orientation="Horizontal" VerticalAlignment="Center">
                        <Button Height="40" Margin="3" VerticalAlignment="Center" Width="20">
                            <Path Data="M0,5 5,0 5,5 10,0 10,10 5,5 5,10 0,5" Fill="White" HorizontalAlignment="Center" Stroke="Black" VerticalAlignment="Center" />
                        </Button>
                        <Button Height="40" Margin="3" VerticalAlignment="Center" Width="40">
                            <Rectangle Fill="White" Height="20" Stroke="Black" Width="20" />
                        </Button>
                        <Button Height="40" Margin="3" Width="40" Command="{Binding PlayFile}" Name="PlayPause" 
                                Click="PlayPause_Click">
                            <Grid>
                            <Path Name="playIm" Data="M 0,0 20,12 0,24 0,0" Fill="White" 
                                  HorizontalAlignment="Center" Stroke="Black" VerticalAlignment="Center" />
                            <Path Name="pauseIm" Opacity="0" Fill="White" Stroke="Black" Data="M1,0 1,24 6,24 6,0Z M10,0 10,24 15,24 15,0Z" 
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Center"/>
                            </Grid>
                        </Button>
                        <Button Height="40" Margin="3" VerticalAlignment="Center" Width="20">
                            <Path Data="M0,0 5,5 5,0 10,5 5,10 5,5 0,10 V 0 " Fill="White" HorizontalAlignment="Center" Stroke="Black" VerticalAlignment="Center" />
                        </Button>
                    </StackPanel>

                    <Button Click="MLbtnClick" Content="Media Library" FontFamily="Segoe UI" Foreground="White" Grid.Column="2" Grid.Row="1" Height="20" HorizontalAlignment="Center" Margin="0,10,0,0" Name="MLbtn" TextBlock.Foreground="White" TextBlock.TextAlignment="Center" TextElement.Foreground="White" VerticalAlignment="Top" Width="80" />
                    <Button Click="PrefBtnClick" Content="Preferences" Grid.Column="2" Grid.Row="1" Height="20" HorizontalAlignment="Center" Margin="0,0,0,10" Name="pref_btn" TextBlock.TextAlignment="Center" VerticalAlignment="Bottom" Width="80" />
                    <TextBlock Grid.Column="0" TextAlignment="Center">
                        <Run Text="{Binding Path=Value, ElementName=Slider, Converter={StaticResource DoubleConverter}}" /></TextBlock>
                    
                    <TextBlock Grid.Column="3" TextAlignment="Center" Name="FileLengthText">
                        <Run Text="{Binding Path=MaximumValue, Converter={StaticResource DoubleConverter}}"/>
                    </TextBlock>
                    <Button Click="CmpctModeBtnClick" Grid.Column="3" Grid.Row="1" Height="27" HorizontalAlignment="Center" Margin="16,5,20,0" Name="cmpctMode_btn" Padding="0,4,0,0" VerticalAlignment="Top" Width="27">
                        <Path Data="M13,17 L12,5 L10,8 C10,8 6,3 0,5 L0,11 C3,9 6,10 5,13 L2,16 z" Fill="White" HorizontalAlignment="Center" Stroke="Black" VerticalAlignment="Center" />
                    </Button>
                    <Button Click="PlwindowBtnClick" Grid.Column="3" Grid.Row="1" Height="25" HorizontalAlignment="Center" 
                            Margin="16,0,20,5" Name="plwindow_btn" VerticalAlignment="Bottom" Width="26">
                        <Path Data="M0,0 4,0 4,4 0,4 0,0 M6,0 21,0 21,4 6,4 6,0                                      
                              M0,6 0,10 4,10 4,6 0,6 M6,6 21,6 21,10 6,10 6,6                                     
                              M0,12 0,16 4,16 4,12 0,12 M6,12 21,12 21,16 6,16 6,12" Fill="White" 
                              HorizontalAlignment="Center" Stroke="Black" StrokeThickness="1" VerticalAlignment="Center" />
                    </Button>
                </Grid>
            </Border>
            <TextBox AcceptsReturn="True" AcceptsTab="True" Background="{DynamicResource MyBackTitleBrush}" 
                     DockPanel.Dock="Left" FontSize="14" Height="Auto" IsReadOnly="True" Name="Lyrics_tbox" 
                     Text="" TextWrapping="Wrap" Width="250" />
            <Border Background="{DynamicResource MyBackTitleBrush}" DockPanel.Dock="Right" Width="Auto">
                <Grid Width="Auto">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="6*" />
                        <RowDefinition Height="1*" />
                    </Grid.RowDefinitions>
                    <Image Grid.Row="0" Name="CoverHolder" Source="{Binding SelectedSong.Cover}" />
                    <TextBlock FontFamily="Segoe UI" FontSize="11" Foreground="White" Grid.Row="3" TextAlignment="Center" TextWrapping="Wrap"><Run Text="Here you will see some description if song has it" /></TextBlock>
                </Grid>
            </Border>
        </DockPanel>
    </Grid>
</UserControl>
